package ACWing.mathematicalknowledge.欧几里得;
//872. 最大公约数

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2023/1/11 15:23
 */
public class GreatestCommonDivisor {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        while (n--!=0){
            int a=sc.nextInt();
            int b=sc.nextInt();
            System.out.println(gcd(a, b));
        }
    }
    public static int gcd(int a,int b){
        if(b==0){
            return a;
        }else {
            return gcd(b,a%b);
        }
    }
}
